home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / lprsetup.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1995-08-26  |  4.5 KB  |  189 lines

  1. #!/bin/sh
  2. #
  3. # BSD PRINT FILTER SETUP utility for Ghostscript - used and tested on
  4. # SunOS 4.1.3, but I hope it will be useful on other BSD systems
  5. # See documentation for usage
  6. #
  7.  
  8. DEVICES="bjt600.32 bjc600.32 bjc600.24 bjc600.24.3 bjc600.16 bjc600.8 bjc600.8.1 bjc600.1 bjc600.dq"
  9. #FILTERS="if nf tf gf vf df cf rf"
  10. FILTERS="if"
  11.  
  12. # The port your printer is on
  13. PRINTERDEV=/dev/lp1
  14. # The kind of printer (accepted values: 'parallel' and 'serial')
  15. PRINTERTYPE=parallel
  16.  
  17. GSDIR=/usr/local/lib/ghostscript
  18. GSFILTERDIR=$GSDIR/filt
  19. SPOOLDIR=/var/spool
  20. GSIF=unix-lpr.sh
  21. PCAP=printcap.insert
  22.  
  23. PATH=/bin:/usr/bin:/usr/ucb
  24. export PATH
  25.  
  26. if [ ! -w $GSDIR ]; then
  27.   echo "$GSDIR must be writable to create filter directory"
  28.   exit 1
  29. fi
  30.  
  31. echo "
  32. Making links in the filter directory $GSFILTERDIR ...
  33. "
  34.  
  35. #
  36. # Make the directory for holding the filter and links
  37. #
  38. if [ -d $GSFILTERDIR ]; then
  39.   echo "$GSFILTERDIR already exists - not created"
  40. else
  41.   mkdir $GSFILTERDIR
  42. fi
  43. rm -f $GSFILTERDIR/direct
  44. ln -s . $GSFILTERDIR/direct
  45. rm -f $GSFILTERDIR/indirect
  46. ln -s . $GSFILTERDIR/indirect
  47.  
  48. #
  49. # Create a link from each filtertype to the real filter script
  50. #
  51. for filter in $FILTERS
  52. do
  53.   rm -f $GSFILTERDIR/gs$filter
  54.   ln -s  ../$GSIF $GSFILTERDIR/gs$filter
  55. done
  56.  
  57. #
  58. # Create a link from each device to the filter directory
  59. #
  60. for device in $DEVICES
  61. do
  62.   dualqueue=
  63.   case "$device" in
  64.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  65.   esac
  66.   rm -f $GSFILTERDIR/$device
  67.   if [ $dualqueue ]; then
  68.     rm -f $GSFILTERDIR/indirect/$device
  69.     ln -s . $GSFILTERDIR/indirect/$device
  70.   else
  71.     rm -f $GSFILTERDIR/direct/$device
  72.     ln -s . $GSFILTERDIR/direct/$device
  73.   fi
  74. done
  75.  
  76. #
  77. # Create a basic printcap insert - this is made in the CURRENT directory
  78. #
  79. rm -f $PCAP
  80. cat > $PCAP << EOF
  81. # This is an example printcap insert for Ghostscript printers
  82. # You will probably want either to change the names for each printer
  83. # below (first line for each device) to something more sensible, or
  84. # to add additional name entries (eg cdjcolor for cdj500.24)
  85. # The example is shown set up for $PRINTERTYPE printers - you will need
  86. # to alter the entries for different or networked remote printer,
  87. # eg. a remote network printer would have a line something like:
  88. #    :lp=:rm=artemis:rp=LPT1:
  89. # for a PC called artemis, replacing the serial port settings
  90. #
  91. # NB/ This is only an example - it is unlikely to be complete or exactly
  92. # correct for your system, but is designed to illustrate filter names 
  93. # corresponding to the accompanying bsd-if print filter
  94. #
  95. EOF
  96.  
  97. (
  98. previous=undefined
  99. for device in $DEVICES
  100. do
  101.   dualqueue=
  102.   case "$device" in
  103.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  104.   esac
  105.   base="`echo $device | sed 's/\.[0-9][0-9]*$//'`"
  106.   base="`echo $base | sed 's/\.[0-9][0-9]*$//'`"
  107. #
  108. # If device listed with '.dq' suffix, we set up a separate output queue
  109. #
  110.   if [ $dualqueue ]; then
  111.     if [ $base != $previous ]; then
  112.       previous=$base
  113.       echo "\
  114. # Entry for raw device $base.raw
  115. $base.raw|Raw output device $base:\\
  116.     :lp=$PRINTERDEV:\\"
  117.     if test "$PRINTERTYPE" = serial
  118.     then
  119.     echo "br#19200:xc#0177777:\\"
  120.         echo ":ms=-parity,ixon,-opost:\\"
  121.     fi
  122.     echo ":sd=$SPOOLDIR/$base/raw:\\
  123.     :mx#0:sf:sh:rs:"
  124.     fi
  125.     echo "\
  126. # Entry for device $device (output to $base.raw)
  127. $device|Ghostscript device $device:\\
  128.     :lp=/dev/null:\\"
  129.   else
  130.     echo "\
  131. # Entry for device $device
  132. $device|Ghostscript device $device:\\
  133.     :lp=$PRINTERDEV:\\"
  134.     if test "$PRINTERTYPE" = serial
  135.     then
  136.     echo "br#19200:xc#0177777:\\"
  137.         echo ":ms=-parity,ixon,-opost:\\"
  138.     fi
  139.   fi
  140.   echo "\
  141.     :sd=$SPOOLDIR/$base:\\
  142.     :lf=$SPOOLDIR/$base/logfile:\\
  143.     :af=$SPOOLDIR/$base/acct:\\"
  144.   for filter in $FILTERS
  145.   do
  146.     if [ $dualqueue ]; then
  147.       echo "\
  148.     :$filter=$GSFILTERDIR/indirect/$device/gs$filter:\\"
  149.     else
  150.       echo "\
  151.     :$filter=$GSFILTERDIR/direct/$device/gs$filter:\\"
  152.     fi
  153.   done
  154.   echo "\
  155.     :mx#0:sf:sh:rs:"
  156. done
  157. ) >> $PCAP
  158.  
  159. echo "
  160. Example printcap insert file \"$PCAP\" now created"
  161.  
  162. #
  163. # Remind the user what's still to do
  164. #
  165.  
  166. echo "
  167. NB/ You will need to create the following directories, with
  168. appropriate permissions, and do 'touch logfile' and 'touch acct'
  169. in the top level directories (ie. not the 'raw' ones):
  170. "
  171. (
  172. for device in $DEVICES
  173. do
  174.   dualqueue=
  175.   case "$device" in
  176.     *.dq) device=`basename $device .dq` ; dualqueue=t ;;
  177.   esac
  178.   base="`echo $device | sed 's/\.[0-9][0-9]*$//'`"
  179.   base="`echo $base | sed 's/\.[0-9][0-9]*$//'`"
  180.   echo "  $SPOOLDIR/$base"
  181.   if [ $dualqueue ]; then
  182.     echo "  $SPOOLDIR/$base/raw"
  183.   fi
  184. done
  185. ) | sort -u
  186.  
  187. echo "
  188.         + + + "
  189.